library(plotly)
library(quantmod)
library(dplyr)
## set period
from.dat <- as.Date("03/13/19", format = "%m/%d/%y")
to.dat <- as.Date("06/06/19", format = "%m/%d/%y")
## download HSI price data
suppressWarnings(getSymbols("HSI", src = "yahoo", from = from.dat,
to = to.dat))
dHSI <- suppressWarnings(to.daily(HSI))
HSIClose <- Cl(dHSI)
HSIClose <- as.data.frame(HSIClose)
HSIClose <- mutate(HSIClose, time = rownames(HSIClose))
plot_ly(HSIClose, x = ~time, y = ~HSI.Close, type = "area")
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Version 0.4-0 included new data defaults. See ?getSymbols.
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
##
## This message is shown once per session and may be disabled by setting
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## [1] "HSI"